<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nyaa</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
            text-align: center;
            padding-top: 100px;
        }
        h1 {
            color: #333;
        }
        #searchForm {
            margin: 0 auto;
            max-width: 400px;
        }
        label {
            display: block;
            margin-bottom: 10px;
            color: #666;
        }
        input[type="text"] {
            width: calc(100% - 82px); /* 82px 是按钮的宽度加上一些间隔 */
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
        }
        button[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button[type="submit"]:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <h1>Nyaa</h1>
    <form id="searchForm" onsubmit="search(); return false;">
        <!-- <label for="searchText">Nyaa搜索:</label> -->
        <input type="text" id="searchText" name="searchText">
        <button type="submit">Search</button>
    </form>

    <script>
        function search() {
            var searchText = document.getElementById("searchText").value;
            var customLink = "https://nyaa.land/?f=0&c=0_0&q=" + encodeURIComponent(searchText);
            window.location.href = customLink;
        }

        // 监听回车键
        document.getElementById("searchText").addEventListener("keydown", function(event) {
            if (event.keyCode === 13) { // 如果按下的是回车键
                search(); // 执行搜索操作
            }
        });
    </script>
</body>
</html>